package com.fmjr.web.configuration;

import com.fmjr.web.ftlvariables.*;
import freemarker.template.TemplateException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

@Configuration
public class FreeMarkerConfig {
	
	@Autowired
    protected freemarker.template.Configuration configuration;  

	
	
	
	@PostConstruct  
    public void  setSharedVariable(){  
        configuration.setDateFormat("yyyy/MM/dd");  
        configuration.setDateTimeFormat("yyyy-MM-dd HH:mm:ss"); 
  
        configuration.setSharedVariable("userDirective", new UserDirective());  
        configuration.setSharedVariable("dicRadio", new SysDicRadioDirective());
        configuration.setSharedVariable("dicSelect", new SysDicSelectDirective());  
        configuration.setSharedVariable("dicWriter", new SysDicWriterDirective());  

          
          
        try {  
            configuration.setSetting("template_update_delay", "1");  
            configuration.setSetting("default_encoding", "GBK");  
        } catch (TemplateException e) {  
            e.printStackTrace();  
        }  
          
          
    }  
}
